package com.beerq.view.me;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.TextView;

import com.beerq.R;
import com.beerq.model.UserInfo;
import com.beerq.util.Constants;
import com.beerq.util.StringUtil;
import com.beerq.view.BaseActivity;
import com.beerq.view.WebViewActivity;
import com.bumptech.glide.Glide;

public class PersonalInfo extends BaseActivity {



    ImageView mImageView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        statusBarType=1;
        super.onCreate(savedInstanceState);
        setMainContentView(R.layout.activity_personal_info);

        UserInfo userInfo=Constants.userInfo;


        mImageView=(ImageView) findViewById(R.id.img_head_pic);

        setBarTitle("个人信息");

        ((TextView)findViewById(R.id.txt_name)).setText(userInfo.getUserName());

        Glide.with(this).load(userInfo.getHeadPic()).into(mImageView);

        setEvent();

        if(userInfo.getSex()==1){
            ((RadioButton)findViewById(R.id.rb_man)).setChecked(true);
        }else{
            ((RadioButton)findViewById(R.id.rb_woman)).setChecked(true);
        }


        setRightTitle("保存", new View.OnClickListener() {
            @Override
            public void onClick(View view) {

            }
        });


        String phoneNo=userInfo.getPhoneNo();

        if(!StringUtil.isEmpty(phoneNo)){
            ((TextView)findViewById(R.id.txt_phone_number)).setText(phoneNo.substring(0,3)+"****"+phoneNo.substring(7,11));
        }
    }

    private void setEvent(){
        findViewById(R.id.rel_address_manager).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(mContext,WebViewActivity.class);
                intent.putExtra("url", Constants.domain+"/#/mangeraddress");
                startActivity(intent);
            }
        });
    }


}
